// import * as api from '../../api/index'
// import * as mine from '../../api/mine'

// const getUrlParam = function (str, name) {
//   var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
//   var r = str.match(reg)
//   if (r !== null) return decodeURI(r[2])
//   return ''
// }
// import { config } from '../../utils/config'

Page({
  data: {
    bannerList: [],
    fund: {},
    goods: [],
    currentPage: 1,
    hasNextPage: true,
    total: '',
    categoryIdThree: 13,
    fid: '',
    onLine: '',
    userLevel: '',
    showSignBox: false,
    userType: 0,
    menuList: [],
    skeletonLoading: true,
    goodList: []
  },
  onLoad() {
    let banner = [{ imageUrl: '/assets/index/4.jpg' }, { imageUrl: '/assets/index/4.jpg' }]
    let menuList = []
    for (let i = 0; i < 8; i++) {
      menuList.push({
        name: '我是按钮' + (i + 1)
      })
    }
    setTimeout(() => {
      this.setData({
        bannerList: banner,
        menuList,
        goodList: [1, 1, 1, 1, 1],
        //hideHead: true
        skeletonLoading: false
      })
    }, 2500)

    // setTimeout(() => {
    //   this.setData({
    //     hideHead: true
    //   })
    // }, 1500)
  },
  // async onShow() {
  //   let pages = getCurrentPages()
  //   let currentPage = pages[pages.length - 1]
  //   let options = currentPage.options

  //   let pid = '', fid = ''
  //   let scene = options.scene

  //   if (scene) {
  //     pid = getUrlParam(decodeURIComponent(scene), 'pid')
  //     fid = getUrlParam(decodeURIComponent(scene), 'fid')
  //     wx.setStorageSync('pid', pid)
  //     wx.setStorageSync('fid', fid)
  //   }
  //   else if (options.pid) {
  //     pid = options.pid || ''
  //   }

  //   else if (options.fid) {
  //     fid = options.fid || ''
  //   }

  //   let bannerList = await api.getBannerList().catch((e) => { console.log(e) })
  //   let res = await mine.get_user_info().catch((e) => { console.log(e) })
  //   this.setData({
  //     currentPage: 1,
  //     hasNextPage: true,
  //     total: '',
  //     onLine: res.online,
  //     userLevel: res.userLevel,
  //     bannerList: bannerList,
  //     userType: res.userType
  //   })
  // },
  handle_jump_page(e) {

    let { url } = e.currentTarget.dataset
    if (this.data.onLine == 'N') {
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }
    else {
      wx.navigateTo({
        url: url
      })
    }
  },
  close_sign_box() {
    this.setData({
      showSignBox: false
    })
  },
  jump_sign_box() {
    if (this.data.onLine == 'N') {
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }
    else {
      wx.navigateTo({
        url: url
      })
    }
  }
})


